
import { Rule, RuleType } from "@midwayjs/validate";

/**
 * 志愿队伍项
 */
export class VolunteerTeamDto {
	@Rule(RuleType.number().required().min(0))
	teamId: number;

	@Rule(RuleType.number().required().min(1))
	sort: number;
}

/**
 * 创建/更新教师志愿
 */
export class CreateTeacherVolunteerDto {
	@Rule(RuleType.number().required().min(0))
	groupId: number;

	@Rule(RuleType.number().required().min(0))
	teacherId: number;

	@Rule(
		RuleType.array()
			.required()
			.min(1)
			.items(
				RuleType.object().keys({
					teamId: RuleType.number().required().min(0),
					sort: RuleType.number().required().min(1),
				})
			)
	)
	teams: Array<VolunteerTeamDto>;
}

/**
 * 更新教师志愿
 */
export class UpdateTeacherVolunteerDto extends CreateTeacherVolunteerDto { }

/**
 * 查询教师志愿
 */
export class QueryTeacherVolunteerDto {
	@Rule(RuleType.number().optional().min(0))
	groupId?: number;

	@Rule(RuleType.number().optional().min(0))
	teacherId?: number;

	@Rule(RuleType.number().optional().min(0))
	teamId?: number;

	@Rule(RuleType.number().optional().min(0))
	pageNum?: number;

	@Rule(RuleType.number().optional().min(0))
	pageSize?: number;

	// 新增搜索字段
	@Rule(RuleType.string().optional().allow('').max(100))
	groupName?: string;

	@Rule(RuleType.string().optional().allow('').max(100))
	teamName?: string;
}

/**
 * 删除教师志愿
 */
export class DeleteTeacherVolunteerDto {
	@Rule(RuleType.number().required().min(0))
	groupId: number;

	@Rule(RuleType.number().required().min(0))
	teacherId: number;

	@Rule(RuleType.array().required().min(1).items(RuleType.number().min(0)))
	teamIds: Array<number>;
}
